<!-- 项目管理 -->
<template>
  <dxtable
    v-if="kxcfdsf"
    :dataJson="dataJson"
    :portUrl="portUrl"
    :formJson="formJson"
    :qx="qx"
    :showdr="true"
    sjname="courseManagement"
    :ewcsobj="{ xxid: xxid }"
    :headBtn="headBtnw"
    ref="databale"
  ></dxtable>
</template>
<script lang="ts" setup>
import dxtable from "../../../../components/util/dxtable.vue";
import sort from "../../../../components/util/sort.vue";
import { dxget, dxpost } from "../../../../util/index";
import { NButton, NImage, NTag } from "naive-ui";
import { h, ref, reactive } from "vue";
const fdfdsgta = ref([]);
const databale = ref();
const kxxzcre = ref([]);
const kxcfdsf = ref();
const headBtnw = ref([
  {
    name: "下载模版",
    jy: true,
    type: "default",
    clickFun: () => {
      window.location.href =
        "https://duxinggj-1251133427.cos.ap-guangzhou.myqcloud.com/case/yuyue/%E6%95%99%E5%B8%88%E6%A8%A1%E6%9D%BF.xlsx";
    },
  },
]);
const jxcxfd = [
  {
    label: "1班",
    value: "1班",
  },
  {
    label: "2班",
    value: "2班",
  },
  {
    label: "3班",
    value: "3班",
  },
  {
    label: "4班",
    value: "4班",
  },
  {
    label: "5班",
    value: "5班",
  },
  {
    label: "6班",
    value: "6班",
  },
  {
    label: "7班",
    value: "7班",
  },
];
const initeer = () => {
  databale.value.initDataExpose();
};
let dataJson = [
  {
    title: "教师姓名",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "name",
    width: "",
    search: true,
    istable: true,
    required: false,
  },
  {
    title: "手机号",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "phone",
    width: "",
    search: true,
    istable: true,
    required: false,
  },
  {
    title: "年级",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "nianji",
    width: "",
    search: false,
    istable: true,
    required: false,
    render: (row) => {
      try {
        const nianjiid = kxxzcre.value.filter((a) => row.id == a.bzrid)[0]
          .nianjiid;
        return fdfdsgta.value.filter((a) => a.value == nianjiid)[0].label;
      } catch (e) {
        return "--";
      }

      // const xcgrte = [];
      // fdfdsgta.value.map((a) => {
      //   row.nianji.split(",").map((b) => {
      //     if (a.value == b) {
      //       xcgrte.push(a.label);
      //     }
      //   });
      // });
      // try {
      //   row.nianji = row.nianji.split(",");
      //   row.banji = row.banji.split(",");
      //   row.jiaose = row.jiaose.split(",");
      // } catch (e) {}
      // return xcgrte.join(",");
    },
  },
  {
    title: "班级",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "banji",
    width: "",
    search: false,
    istable: true,
    required: false,
    render: (row) => {
      try {
        return kxxzcre.value.filter((a) => row.id == a.bzrid)[0].name;
      } catch (e) {
        return "--";
      }
    },
  },
  {
    title: "角色",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "jiaose",
    width: "",
    search: false,
    istable: true,
    required: false,
    render: (row) => {
      row.jiaose = row.jiaose.split(",");
      try {
        if (kxxzcre.value.filter((a) => row.id == a.bzrid)[0].name) {
          return row.jiaose + "," + "班主任";
        }
      } catch (e) {}

      return row.jiaose;
    },
  },

  {
    title: "排序",
    width: 100,
    render: (row) => {
      row.sjk = "xtgx"; //数据库
      row.databaseName = "keyEnterprise"; //表名
      return h(sort, {
        row,
        onCallBack: () => {
          initeer();
        },
      });
    },
  },
  {
    title: "添加时间",
    key: "addTime",
    width: 150,
  },
];

const qx = {
  DeletePermissionID: "123456", //删除
  EditPermissionIdentifier: "cschoolManagementdelbj", // 编辑
  NewPermissionIdentifier: "cschoolManagementdelxz", // 新建
  ViewPermissionID: "cschoolManagementdelck", // 查看
};
const xxid = localStorage.xxid;
const portUrl = "courseManagement/bjsList/bjsList?xxid=" + localStorage.xxid;

let formJson = reactive([
  {
    title: "教师姓名",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "name",
    width: "",
    search: false,
    istable: true,
    required: true,
  },
  {
    title: "手机号",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "phone",
    width: "",
    search: false,
    istable: true,
    required: true,
  },
  // {
  //   title: "年级",
  //   type: "select",
  //   multiple: true,
  //   options: [],
  //   val: "",
  //   icon: "dx-shurukuang",
  //   span: 24,
  //   key: "nianji",
  //   width: "",
  //   search: false,
  //   istable: true,
  //   required: false,
  // },
  // {
  //   title: "班级",
  //   type: "select",
  //   multiple: true,
  //   options: jxcxfd,
  //   val: "",
  //   icon: "dx-shurukuang",
  //   span: 24,
  //   key: "banji",
  //   width: "",
  //   search: false,
  //   istable: true,
  //   required: false,
  // },
  {
    title: "角色",
    type: "select",
    multiple: true,
    options: [],
    val: "",
    icon: "dx-shurukuang",
    span: 24,
    key: "jiaose",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "密码",
    type: "input",
    val: "123456",
    icon: "dx-shurukuang",
    span: 12,
    key: "paw",
    width: "",
    search: false,
    istable: true,
    required: true,
  },
  {
    title: "",
    type: "",
    val: localStorage.xxid,
    span: 24,
    key: "xxid",
    istable: true,
    required: true,
  },
]);
const czFun = {
  fun: (row) => {
    return [
      h(
        NButton,
        {
          type: "info",
          quaternary: true,
          onClick: async (e) => {},
        },
        "复制代码"
      ),
    ];
  },
};

// 获取字典内容
const xtgxxmfl = async () => {
  const { data }: any = await dxget("dxgjAdmin/getzd/getzdJsList?ids=316,343");
  await getabanji();
  fdfdsgta.value = data[0];
  formJson[2].options = data[1];
  kxcfdsf.value = true;
};
xtgxxmfl();

const getabanji = async () => {
  const { data }: any = await dxget(
    "courseManagement/banji/banji?xxid=6&page=1&pageSize=999"
  );
  console.log(data.data);
  kxxzcre.value = data.data;
};
</script>
<style scoped></style>
